home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / userbox / publicdomain / vim-4.2 / src / macros.h < prev    next >
C/C++ Source or Header  |  1996-06-09  |  2KB  |  69 lines

  1. /* vi:set ts=4 sw=4:
  2.  *
  3.  * VIM - Vi IMproved        by Bram Moolenaar
  4.  *
  5.  * Do ":help uganda"  in Vim to read copying and usage conditions.
  6.  * Do ":help credits" in Vim to see a list of people who contributed.
  7.  */
  8.  
  9. /*
  10.  * macros.h: macro definitions for often used code
  11.  */
  12.  
  13. /*
  14.  * pchar(lp, c) - put character 'c' at position 'lp'
  15.  */
  16. #define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
  17.  
  18. /*
  19.  * Position comparisons
  20.  */
  21. #define lt(a, b) (((a).lnum != (b).lnum) \
  22.                    ? ((a).lnum < (b).lnum) : ((a).col < (b).col))
  23.  
  24. #define ltoreq(a, b) (((a).lnum != (b).lnum) \
  25.                    ? ((a).lnum < (b).lnum) : ((a).col <= (b).col))
  26.  
  27. #define equal(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
  28.  
  29. /*
  30.  * lineempty() - return TRUE if the line is empty
  31.  */
  32. #define lineempty(p) (*ml_get(p) == NUL)
  33.  
  34. /*
  35.  * bufempty() - return TRUE if the current buffer is empty
  36.  */
  37. #define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_t)1) == NUL)
  38.  
  39. /*
  40.  * On some systems toupper()/tolower() only work on lower/uppercase characters
  41.  */
  42. #ifdef BROKEN_TOUPPER
  43. # define TO_UPPER(c)    (islower(c) ? toupper(c) : (c))
  44. # define TO_LOWER(c)    (isupper(c) ? tolower(c) : (c))
  45. #else
  46. # define TO_UPPER        toupper
  47. # define TO_LOWER        tolower
  48. #endif
  49.  
  50. #ifdef HAVE_LANGMAP
  51. /* 
  52.  * Adjust chars in a language according to 'langmap' option.
  53.  * NOTE that there is NO overhead if 'langmap' is not set; but even
  54.  * when set we only have to do 2 ifs and an array lookup.
  55.  * Don't apply 'langmap' if the character comes from the Stuff buffer.
  56.  * The do-while is just to ignore a ';' after the macro.
  57.  */
  58. # define LANGMAP_ADJUST(c, condition) do { \
  59.         if (*p_langmap && (condition) && !KeyStuffed && (c) < 256) \
  60.             c = langmap_mapchar[c]; \
  61.     } while (0)
  62. #endif
  63.  
  64. /*
  65.  * isbreak() is used very often if 'linebreak' is set, use a macro to make
  66.  * it work fast.
  67.  */
  68. #define isbreak(c) (breakat_flags[(char_u)(c)])
  69.